package com.zhj.helloframework.mvc.render.impl;

import com.zhj.helloframework.mvc.RequestProcessorChain;
import com.zhj.helloframework.mvc.render.ResultRender;

import javax.servlet.http.HttpServletResponse;

/**
 * @Author: zhj
 * @Description: 异常渲染器
 * @Date: 2021/11/16 15:31
 * @Version: 1.0
 */
public class InternalErrorResultRender implements ResultRender {

    private String errorMsg;

    public InternalErrorResultRender(String errorMsg) {
        this.errorMsg = errorMsg;
    }

    @Override
    public void render(RequestProcessorChain requestProcessorChain) throws Exception {
        // 如果发生异常，那么就把response状态码设置成500
        requestProcessorChain.getResponse().sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR,errorMsg);
    }
}
